package tp.pr5.commands;

import tp.pr5.Game;
import tp.pr5.Map;
import tp.pr5.MensajesConst;
import tp.pr5.Player;
import tp.pr5.Room;
import tp.pr5.commands.exceptions.CommandExecutionException;
import tp.pr5.commands.exceptions.WrongCommandFormatException;

@SuppressWarnings("unused")  public class QuitCommand implements Command{

	private Game _game;
	private Player _friki;
	private Room _habitacion;
	
	public QuitCommand() {
		this._game=null;
		this._friki=null;
		this._habitacion=null;
	}
	public void configureContext(Game g, Map m, Player p) {
		this._friki=p;
		this._habitacion=m.getCurrentRoom();
		this._game=g;
	}
	@Override
	public void execute() throws CommandExecutionException {

		this._game.requestQuit();
	}

	@Override
	public String getHelp() {
		return MensajesConst.hQuit;
	}

	@Override
	public Command parse(String cad)
			throws WrongCommandFormatException {
		if (cad.lastIndexOf(' ') != -1)
			throw new WrongCommandFormatException();

		else if (cad.equalsIgnoreCase("QUIT")
				|| cad.equalsIgnoreCase("SALIR"))
		{
		//	this._friki = execContext.getPlayer();
		//	this._habitacion = execContext.getCurrentRoom();
		//	this._game=execContext;
			return this;
		}
		throw new WrongCommandFormatException();
	}
	
}
